package com.old.controller;


import com.old.service.UploadFile;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

@Controller
public class UploadController {
    @Autowired
    private UploadFile handler;


    @RequestMapping("/uploadMultipartFile")
    @ResponseBody
    public String uploadMultipartFile(MultipartFile multipartFile) throws IOException {
        if(multipartFile.isEmpty()){
            return "请选择上传文件！！";
        }

        return handler.uploadMultipartFile(multipartFile);
    }


    @RequestMapping("/uploadFile")
    @ResponseBody
    public String uploadFile(File file) throws Exception {
        if(!file.exists()){
            return "请选择上传文件！！";
        }

        return handler.uploadFile(file);
    }
}
